document.writeln("<header class=\"am-topbar am-topbar-inverse admin-header\">");
document.writeln("    <div class=\"am-topbar-brand\">");
document.writeln("        <strong>XXXX</strong>");
document.writeln("        <small>考勤系统</small>");
document.writeln("    </div>");
document.writeln("");
document.writeln("    <button class=\"am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only\"");
document.writeln("            data-am-collapse=\"{target: \'#topbar-collapse\'}\"><span class=\"am-sr-only\">导航切换</span> <span");
document.writeln("            class=\"am-icon-bars\"></span></button>");
document.writeln("");
document.writeln("    <div class=\"am-collapse am-topbar-collapse\" id=\"topbar-collapse\">");
document.writeln("");
document.writeln("        <ul class=\"am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list\">");
document.writeln("            <li><a href=\"../html/employeeApply.html\"><span class=\"am-icon-envelope-o\"></span> 消息 <span");
document.writeln("                    class=\"am-badge am-badge-warning\" id=\"message\">0</span></a></li>");
document.writeln("            <li class=\"am-dropdown\" data-am-dropdown>");
document.writeln("                <a class=\"am-dropdown-toggle\" data-am-dropdown-toggle href=\"javascript:;\">");
document.writeln("                    <span class=\"am-icon-users\" id=\"loginName\"></span> <span class=\"am-icon-caret-down\"></span>");
document.writeln("                </a>");
document.writeln("                <ul class=\"am-dropdown-content\">");
document.writeln("                    <li><a href=\"../html/personalInfo.html\"><span class=\"am-icon-cog\"></span> 设置</a></li>");
document.writeln("                    <li><a href=\"../logout\"><span class=\"am-icon-power-off\"></span> 退出</a></li>");
document.writeln("                </ul>");
document.writeln("            </li>");
document.writeln("            <li class=\"am-hide-sm-only\"><a href=\"javascript:;\" id=\"admin-fullscreen\"><span");
document.writeln("                    class=\"am-icon-arrows-alt\"></span> <span class=\"admin-fullText\">开启全屏</span></a></li>");
document.writeln("        </ul>");
document.writeln("    </div>");
document.writeln("</header>");
document.writeln("<div id=\'Loading\'");
document.writeln("     style=\"position:absolute;z-index:1000;top:0px;left:0px;width:100%;height:120%;background: #FCFCFC;");
document.writeln("      no-repeat;");
document.writeln("     text-align:center;padding-top: 20%;\">");
document.writeln("    <h1>");
document.writeln("        <img src=\'../image/loading.gif\'/>");
document.writeln("        <font style=\"color:rgb(67,142,185);\">正在加载，请稍后...</font>");
document.writeln("    </h1>");
document.writeln("</div>");
var current = {};

function closes() {
    $("#Loading").fadeOut("normal", function () {
        $(this).remove();
    });
}
var pc;
$.parser.onComplete = function () {
    if (pc) clearTimeout(pc);
    pc = setTimeout(closes, 100);
}

$(document).ready(function () {

    $.ajax({
        type: 'get',
        dataType: 'json',
        async: false,
        url: '../employee/current',
        success: function (result) {
            if (result.success) {
                if (result.username == "anonymousUser") {
                    loginName.innerHTML = " 请登录";
                    message.innerHTML = "";
                } else {
                    loginName.innerHTML = " " + result.username;
                    current.uid = result.uid;
                    current.username = result.username;
                    current.name = result.name;
                    current.sex = result.sex;
                    current.job = result.job[0].authority;

                    var state;
                    if (current.job == 1) {   //总经理
                        state = 2;
                    } else if (current.job == 2) { //副经理
                        state = 1;
                    } else if (current.job == 5) { //部门经理
                        state = 0;
                    } else {
                        state = 6;
                    }
                    $.ajax({
                        type: 'get',
                        dataType: 'json',
                        async: false,
                        url: '../apply?state='+state,
                        success: function (result) {
                            message.innerHTML = "" + result.result.list.length;
                        }
                    });
                }
            } else {
                $.messager.show({    // show error message
                    title: 'Error',
                    msg: result.message
                });
            }
        }
    });
})